package com.coolingme.springboot.nacos;

import com.alibaba.nacos.api.config.annotation.NacosValue;
import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Nacos注册中心测试
 * NacosPropertySource：配置注册中心，且当前类中的属性需要动态刷新
 *
 * @author wangyue
 * @date 2022/10/06 10:11
 */
@RestController
@NacosPropertySource(dataId = "spring-boot-nacos-example", autoRefreshed = true)
public class NacosConfigController {

    /**
     * 冒号后面表示默认值
     */
    @NacosValue(value = "${info:world}", autoRefreshed = true)
    private String info;

    @GetMapping("/info")
    public String getInfo() {
        return "Hello " + info;
    }

}
